import type { Base, Page } from "@/api/types";
import { http } from "@/utils/http";

export type Message = Base & {
  title?: string;
  type?: string;
  content?: string;
  status?: string;
  isRead?: boolean;
  receivers?: Array<string>;
  sender?: string;
  sendTime?: string;
};

export const getMessageSendList = (params?: Message) => {
  return http.request<Page<Message>>("get", "/message/send", params);
};
export const getMessageReceiveList = (params?: Message) => {
  return http.request<Page<Message>>("get", "/message/receive", params);
};
export const addMessage = (data?: Message) => {
  return http.request<boolean>("post", "/message", {}, { data });
};
export const updateMessage = (data?: Message) => {
  return http.request<boolean>("put", "/message", {}, { data });
};
export const sendMessage = (id: string) => {
  return http.request<boolean>("post", `/message/${id}`);
};
export const recallMessage = (id: string) => {
  return http.request<boolean>("delete", `/message/recall/${id}`);
};
export const deleteMessage = (id: string) => {
  return http.request<boolean>("delete", "/message", { id: id });
};
export const getMessageById = (id: string) => {
  return http.request<Message>("get", `/message/${id}`);
};
export const readMessage = (id: string) => {
  return http.request<Message>("get", `/message/read/${id}`);
};
